<template>
    <div class="content">
        <div class="top-content">
            <div class="box">
                <div class="left-box">
                    实验室用低温操作台（工作台）、血液低温操作台（工作台）、医用洁净工作台、低温洁净工作台、低温配血台、血液配血台、低温操作台（工作台）价格、低温操作台（工作台）厂家
                </div>
                <div class="top-content-right">
                    <div class="tel-box">
                        咨询热线：{{ webMessage.tel1 }} 
                    </div>
                </div>
            </div>
        </div>
        <div class="top-list banner-box">
            <div class="box-message">
                <div class="img">
                    <img src="../assets/top/logo.png" alt="">
                </div>
                <div class="box">
                    <div class="list-box">
                        <div class="item" @click="gotoweb('/')">网站首页</div>
                        <div class="item" @click="gotoChanpinListBtn()">产品中心</div>
                        <div class="item" v-for="(item, index) in userRouterJson" :key="index"
                            @click="gotoweb(item.path)">
                            {{ item.title }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import router from '@/router/index.js'
import { getTopList, getWebXinxi } from '@/api/viewapi.js'
import { ref, reactive, onMounted } from 'vue'


const webMessage = ref({})

const topList = ref([])

const gotoweb = (path) => {
    router.push(path)
}

const gotoChanpinListBtn = () => {
    let id = topList.value[0].record_id
    router.push({ path: '/chanpinlist', query: { id: id } })
}

const getWebMessage = () => {
    getWebXinxi().then((res) => {
        webMessage.value = res.data.data
        console.log(res);
    })
}

const _getTopList = () => {
    getTopList().then((res) => {
        topList.value = res.data.toplist_ids
        console.log(res);
    })
}

// 跳转商品列表 
const gotoChanpin = (id) => {
    router.push({ path: '/chanpinlist', query: { id: id } })
}

// 路由图 
const userRouterJson = [
    {
        title: '新闻中心',
        path: '/news'
    }, {
        title: '关于我们',
        path: '/about'
    }, {
        title: '联系我们',
        path: '/telme'
    }
]


onMounted(() => {
    getWebMessage()
    _getTopList()
})
</script>

<style scoped lang="scss">
// 取消显示pc端 显示手机端
@media screen and (max-width: 799px) {
    .content {
        .top-content {
            .box {
                .left-box {
                    padding: 14px 4px;
                    background: linear-gradient(0deg, rgba(0, 109, 196, 1) 0%, rgba(28, 189, 240, 1) 100%);
                    color: white;
                }

                .top-content-right {
                    display: none;
                }
            }
        }

        .top-list {

            .box {
                .list-box {
                    display: grid;
                    grid-template-columns: repeat(4, 1fr);
                    /* 创建4列，每列占1fr */
                    gap: 2px;

                    /* 设置列与列之间的间距 */
                    .item {
                        padding: 14px 0;
                        font-size: 14px;
                        text-align: center;
                        background-color: #00a0e9;
                        color: white;
                    }
                }
            }
        }
    }
}

// 显示pc端
@media (min-width: 800px) {
    .phone {
        display: none;
    }

    .content {
        border-bottom: 1px solid gainsboro;
        .top-content {
            background-color: rgb(245, 245, 245);

            .box {
                margin: 0 auto;
                max-width: 1400px;
                padding: 10px 40px;
                display: flex;
                justify-content: space-between;
                font-size: 14px;
                color: #999999;


                .left-box {
                    display: flex;

                    .item {
                        
                        cursor: pointer;
                        margin-right: 40px;
                    }
                }

                .top-content-right {
                    .tel-box {}
                }
            }
        }

        .top-list {
            padding: 20px 0;
            background-color: white;

            .box-message {
                display: flex;
                justify-content: space-between;
                .img {
                    img {}
                }

                .box {
                    padding: 10px 0;
                    .list-box {
                        display: flex;
                        font-size: 16px;
                        justify-content: space-between;

                        .item {
                            line-height: 40px;
                            padding: 0 30px;
                            cursor: pointer;
                            transition: transform 0.3s ease, background-color 0.3s ease;
                            border-radius: 4px;
                            margin-left: 4px;
                            color: black;
                        }
                    }
                }
            }
        }
    }
}
</style>
